home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16772 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: pangea.Stanford.EDU!karish
  2. From: karish@pangea.Stanford.EDU (Chuck Karish)
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
  4. Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
  5. Date: 12 Apr 1996 00:51:13 GMT
  6. Organization: Mindcraft, Inc.
  7. Message-ID: <4kk9e1$he1@nntp.Stanford.EDU>
  8. NNTP-Posting-Host: pangea.stanford.edu
  9.  
  10. Dave Emery roped me into this discussion, and now that I see how
  11. nastily some people choose to express their frustration with a
  12. ill-defined problem, I'm not sure whether to thank him.
  13.  
  14. Anyway, the problem as he posed it to me is whether code like
  15.  
  16.     /* sample 1 */
  17.     char buf[100];
  18.     ...
  19.     i = read (fd, buf, 200);
  20.  
  21. is legal under the C and/or POSIX.1 standards.
  22.  
  23. My understanding is that it conforms to the C and the POSIX.1
  24. standards but that it is not guaranteed to work.
  25.  
  26. Neither ISO/IEC 9945-1 (POSIX.1) nor ISO/IEC 9989 (Standard C)
  27. specifies the details of storage in the calling environment.
  28. This means that a conforming implementation could, but need not,
  29. automatically adjust storage to allow 200 bytes of data to be
  30. stored though only 100 bytes were allocated.
  31.  
  32. POSIX.1 specifically allows the implementation to report an error
  33. for a condition that is not spelled out in the Standard:
  34.  
  35.      Implementations may support additional errors not included
  36.      in this clause, may generate errors included in this clause
  37.      under circumstances other than those described in this
  38.      clause, or may contain extensions or limitations that
  39.      prevent some errors from occurring.
  40.  
  41. My understanding is that this thread started around a discussion
  42. of bounds checking under Linux that seems to go beyond the
  43. requirements of POSIX.1.  According to the wording quoted
  44. above, such extra stringency is allowed by POSIX.1.
  45.  
  46. There are a lot of things that are intentionally not spelled
  47. out by standards.  Sometimes this is because the standard
  48. writers want to limit the scope of the document to keep it
  49. legible and usable, and sometimes it's because they don't want
  50. to preclude implementors from offering usable products
  51. based on current technology or from adding capabilities and
  52. value to future products.
  53.  
  54. Anyone who craves a standard that describes every possible
  55. aspect of system behavior with complete logical precision
  56. is invited to study the later writings of Rene Descartes
  57. and then get back to us.
  58.  
  59. --
  60.  
  61.     Chuck Karish          karish@mindcraft.com
  62.     (415) 323-9000 x117   karish@pangea.stanford.edu
  63.